package com.weyoung.app.config;

import com.coze.openapi.service.auth.TokenAuth;
import com.coze.openapi.service.service.CozeAPI;
import com.coze.openapi.service.service.chat.ChatMessageService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

@Configuration
@EnableScheduling
public class CozeConfig {

    @Value("${coze.token}")
    private String token;

    @Value("${coze.base-url}")
    private String baseUrl;

    @Bean
    public CozeAPI cozeAPI() {
        TokenAuth authCli = new TokenAuth(token);
        return new CozeAPI.Builder()
                .baseURL(baseUrl)
                .auth(authCli)
                .readTimeout(10000)
                .build();
    }

    @Bean
    public ChatMessageService chatMessageService(CozeAPI cozeAPI) {
        return cozeAPI.chat().message();
    }
} 